/**
 * 购物车页面
 */

const router = require('koa-router')();

const {
  getCardListService,
  delCartService,
  addToCardService,
  updateCardService

} = require('../../service/cardServer')

//获取商品列表
router.get("/api/miniapps/getCardList", async (ctx, next) => {
  let params = ctx.request.query;
  await getCardListService(ctx, params);
})

//删除购物车商品
router.post('/api/miniapps/delCart', async (ctx, next) => {
  let params = ctx.request.body;
  console.log("2134")
  console.log(params.ids)
  await delCartService(ctx, params);
})

//添加购物车商品
router.post('/api/miniapps/addCart', async (ctx, next) => {
  let params = ctx.request.body;
  console.log("11111")
  await addToCardService(ctx, params);
})

//更新购物车数量
router.post('/api/miniapps/updateCart', async (ctx, next) => {
  let params = ctx.request.body;
  console.log("11111")
  console.log(params)
  await updateCardService(ctx, params);
})
module.exports = router;